<?php
if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
/**
 *
 */
class CI_Layout
{
    public $layout;
    public function __construct($params = array('main'))
    {

        $this->layout = 'layouts' . DIRECTORY_SEPARATOR . $params[0];
    }
    public function view($view, $data = null, $flag = false)
    {
        $ci = &get_instance();
        $data['content'] = $ci->load->view($view, $data, true); //这里的第三个参数true代表不输出，如果是false就会输出，默认是false，和thinkphp里的display和assign类似，这里用第三个参数来控制
        if ($flag) {
            $view = $ci->load->view($this->layout, $data, true);
            return $view;
        } else {
            $ci->load->view($this->layout, $data, false);
        }
    }
}
